from django.db import models
from string import Template
import pymysql
connect = pymysql.connect(host='81.70.27.234',port=3306,user='root',password='010825lwj',db='filmInfo',connect_timeout=28800,cursorclass = pymysql.cursors.DictCursor)
cursor = connect.cursor()
# Create your models here.
#读取表中国家出品电影数目大于十的国家
def req_ratio(year:str)->list:
    req_sql = Template("""
                       select * from ${year}_ratio where value >= 10
                       """)
    cursor.execute(req_sql.substitute(year=year))
    result = cursor.fetchall()
    return result
#读取类型数量和年份的关系
def req_type()->list:
    req_sql = "select * from type_year"
    cursor.execute(req_sql)
    result = cursor.fetchall()
    return result